package com.goldfish666.remote_control.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum DeviceTypeEnum {

    /**
     * 空调
     */
    airConditioner(0,"airConditioner"),

    /**
     * 电视
     */
    tv(1,"tv");


    private int value;

    private String desc;

    DeviceTypeEnum(int option, String desc) {
        this.value = option;
        this.desc = desc;
    }

    @JsonCreator
    public static DeviceTypeEnum fromValue(@JsonProperty("value") final int option) {
        for (DeviceTypeEnum e : DeviceTypeEnum.values()) {
            if (e.value == option) {
                return e;
            }
        }
        return null;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
}
